import java.util.Arrays;

public class SolutionLCP28 {
    public int purchasePlans(int[] nums, int target) {
        Arrays.sort(nums);
        int ans=0;
        int l=0,r=nums.length-1;
        while (l<r){
            while (nums[l]+nums[r]>target && r>l){
                r--;
            }
            ans=(ans+r-l)%1000000007;
            l++;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionLCP28().purchasePlans(new int[]{2,5,3,5},6));
    }
}
